package com.example.starter.work4

import org.apache.rocketmq.client.producer.DefaultMQProducer
import org.apache.rocketmq.common.message.Message

/**
@author whd
@date 2023/10/10 20:15:29
 */
object Producer {
  @JvmStatic
  fun main(args: Array<String>) {
    val producer = DefaultMQProducer("Msg12")
    producer.namesrvAddr = "8.130.168.253:9876"
    try {
      producer.start()
      val topic = "topic"
      val tags = "Tags"
      val body = "hello world11".toByteArray(Charsets.UTF_8)
      val message = Message(topic, tags, body)

      // 发送消息
    } catch (e: Exception) {
      e.printStackTrace()
    } finally {
      producer.shutdown()
    }
  }
}
